
var id;	//id
var type; //类型

$(function () {
	//获取传来的id
	id = $.getUrlParam("id");
	//获取传来的type
	type = $.getUrlParam("type");
	
	console.log("id:" + id + ",type:" + type);
	
	//定义URL
	var url;
	//定义全局函数
	var executeFunction;
	
	switch (type) {
	case '1':
		url = "../order/getSenderInfoById.htm";
		executeFunction = (function(data){
			//发货人性别
			if(data.senderSexual == 1){
				data.senderSexual = '男';
			}else if(data.senderSexual == 2){
				data.senderSexual = '女';
			}
			$("#form" + type).formatForm(data);
			$("#form" + type).css("display","block");
		});
		break;
	case '2':
		url = "../order/getReciverInfoById.htm";
		executeFunction = (function(data){  
			$("#form" + type).formatForm(data);
			$("#form" + type).css("display","block");
		});
		break;
	case '3':
		url = "../order/getCargoInfoById.htm";
		executeFunction = (function(data){
			//货物是否验货 0未检验，1已检验
			if(data.cargoIsCheck == 0){
				data['cargoIsCheck'] = '未检验';
			}else if(data.cargoIsCheck == 1){
				data['cargoIsCheck'] = '已检验';
			}
			//货物是否x光检查 0未检验，1已检验
			if(data.cargoIsXcheck == 0){
				data['cargoIsXcheck'] = '未检验';
			}else if(data.cargoIsXcheck == 1){
				data['cargoIsXcheck'] = '已检验';
			}
			//货物状态：0入库，1出库
			if(data.orderState == 0){
				data['orderState'] = '入库';
			}else if(data.orderState == 1){
				data['orderState'] = '出库';
			}
			$("#form" + type).formatForm(data);
			$("#form" + type).css("display","block");
		});
		break;
	case '4':
		url = "../order/getStorageInfoById.htm";
		executeFunction = (function(data){
			//设置仓库类型：1普通，2冷链
			if(data.storageType == 1){
				data['storageType'] = '普通仓库';
			}else if(data.storageType == 2){
				data['storageType'] = '冷链仓库';
			}
			//设置仓库状态 ：1满仓，2正常，3空仓
			if(data.storageState == 1){
				data['storageState'] = '满仓';
			}else if(data.storageState == 2){
				data['storageState'] = '正常';
			}else if(data.storageState == 3){
				data['storageState'] = '空仓';
			}
			$("#form" + type).formatForm(data);
			$("#form" + type).css("display","block");
		});
		break;
	case '5':
		url = "../order/getTruckPartInfoById.htm";
		executeFunction = (function(data){
			//设置货车类型：1.重型货车2.中型货车3.轻型货车均为两轴车辆4.微型货车
			if(data.truckType == 1){
				data['truckType'] = '重型货车';
			}else if(data.truckType == 2){
				data['truckType'] = '中型货车';
			}else if(data.truckType == 3){
				data['truckType'] = '轻型货车';
			}else if(data.truckType == 4){
				data['truckType'] = '微型货车';
			}
			$("#form" + type).formatForm(data);
			$("#form" + type).css("display","block");
		});
		break;
	case '6':
		url = "../order/getDriverInfoById.htm";
		executeFunction = (function(data){
			$("#form" + type).formatForm(data);
			$("#form" + type).css("display","block");
		});
		break;
	default:
		break;
	}
	
	//ajax请求获取各种详情
	 $.ajax({
	    url: url,
	    cache: false,
	    type: "post",
	    dataType: "json",
	    data: {id: id},
	    success: function (result) {
	        if (result.status == 0) {
	        	var data = result.data;
	        	executeFunction(data);
	        } else {
	            layer.msg('详情显示有误，稍后再试！', {icon: 2});
	        }
	    }
	 });
});







